package main
import (
	"fmt"
)
func judgeMap(name string, scoreMap map[string]int) { // 判断键是否存在
	v, ok := scoreMap[name]
	if ok {
		fmt.Println(v)
	} else {
		fmt.Println("查无此人")
	}
}

func forMap(scoreMap map[string]int) { //遍历
	fmt.Println("================")
	for k, v := range scoreMap {
		fmt.Println(k, v)
	}
}

func deleteKey(scoreMap map[string]int, name string) {
	delete(scoreMap, name)
	fmt.Println("删除" + name + "成功")
}

func main() {
  scoreMap := make(map[string]int, 4)
	scoreMap["zhangsan"] = 85
	scoreMap["lisi"] = 80
	scoreMap["ww"] = 80
	scoreMap["zl"] = 80
	scoreMap["xz"] = 80
	fmt.Println(scoreMap["zhangsan"])
	fmt.Println(scoreMap)
	fmt.Printf("type of scoreMap: %T\n", scoreMap)
  judgeMap("zhangsan", scoreMap)
	judgeMap("aaa", scoreMap)
	forMap(scoreMap)
	deleteKey(scoreMap, "zhangsan")
	fmt.Println(scoreMap)
}
